<?php
/**
 * 后台主页控制器
 * User: ws
 * Date: 2018/7/20
 * Time: 14:39
 */
namespace app\admin\controller;

use app\admin\model\Goods as GoodsModel;
use app\admin\model\Label as LabelModel;
use app\admin\model\Materiel as MaterielModel;
use app\admin\model\Order;
use app\admin\model\Store;

class Index extends Init
{
    function index()
    {
        return  view('index');
    }

    function home()
    {
        $store = Store::where("store_id>0")->count();
        $goods = GoodsModel::where("goods_id>0")->count();
        $label= LabelModel::where("label_id>0")->count();
        $materiel = MaterielModel::where("materiel_id>0")->count();
        $order = Order::where("order_id>0")->count();

        $mysql = db()->query("select VERSION() as version");
        $mysql = $mysql[0]['version'];
        $mysql = empty($mysql)?L('UNKNOWN'):$mysql;
        return  view('home',['mysql'=>$mysql,'store'=>$store,'goods'=>$goods,'label'=>$label,'materiel'=>$materiel,'order'=>$order]);
    }

}
